package com.zzw.basic.io.nio;

import com.zzw.basic.io.nio.handler.BIOSocketHandler;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SocketChannel;
import java.util.concurrent.CountDownLatch;

/**
 * @author zzw
 * @see
 * @since 2018/2/22
 */
public class BlockClient {
    public static void main(String[] args) throws IOException, InterruptedException {

        CountDownLatch countDownLatch = new CountDownLatch(10);

        for (int i = 0;i < 10;i ++){
            SocketChannel socketChannel = SocketChannel.open();
            socketChannel.connect(new InetSocketAddress("localhost", 18080));
            new Thread(new BIOSocketHandler(countDownLatch,socketChannel)).start();
        }

        countDownLatch.await();
        System.out.println("执行完毕");
    }
}
